<!DOCTYPE html>
<html lang="en">
  <head>
      <meta charset="UTF-8">
      <title>jquery选择器使用特点</title>
    <script type="text/javascript" src="script/jquery-3.6.0.min.js"></script>
    <script type="text/javascript">
      window.onload = function() {
        //如果是dom对象获取value
        // var username = document.getElementsById("username");
        // //控制台会报错
        // alert("username value = " + username.value);

        //如果是jquery对象获取value
        var $username = $("#username");
        //控制台不会报错，$username.val()返回undefined
        alert("$username value = " + $username.val());
      }
    </script>
  </head>
  <body>
    用户名 <input type="text" id="username" name="username" value="lmy">
  </body>
</html>